<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:c="http://java.sun.com/jstl/core"
    xmlns:t="http://myfaces.apache.org/tomahawk">
        
    <body>
        <ui:composition template="/./ressources/template/template_member.xhtml">

            <ui:define name="title">
                MC. Member - PROJETS
            </ui:define>
            
            <ui:define name="body">
                <h1>Tableau des porjets en financements</h1>
                <p>
                    <h:form id="listLentProjets" >
                        <h:dataTable value="#{currentUser.listProjetFinance}" styleClass="dvdtable" var="item" border="0" cellpadding="1" cellspacing="0">
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Id"/>
                                </f:facet> 
                                <h:outputText value="#{item.id}"/>
                            </h:column>
                            
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Type"/>
                                </f:facet>
                                <h:outputText value="#{item.projet.type.label}"/>
                            </h:column>
            
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Titre"/>
                                </f:facet>
                                <h:outputText value="#{item.projet.title}"/>
                            </h:column>

                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Investisseur"/>
                                </f:facet>
                                <h:outputText value="#{item.user.prenom}"/>
                                <h:outputText value="#{item.user.nom}"/>
                            </h:column>

                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Date debut"/>
                                    
                                </f:facet>
                                <h:outputText value="#{item.loanStartDate}" rendered="#{item.loanStartDate!=null}"  >
                                    <f:convertDateTime pattern="dd/MM/yyyy"/>
                                </h:outputText>

                                <h:outputText value="Indisponible" rendered="#{item.loanStartDate==null}" />

                            </h:column>
                            
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Date fin"/>
                                </f:facet>
                                <h:outputText value="#{item.loanEndDate}" rendered="#{item.loanEndDate!=null}"  >
                                    <f:convertDateTime pattern="dd/MM/yyyy"/>
                                </h:outputText>

                                <h:outputText value="Indisponible" rendered="#{item.loanEndDate==null}" />                            
                            </h:column>

                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Etat"/>
                                </f:facet>
                                <h:commandLink action="#{currentuser.validateLent}" rendered="#{item.loanWaitingState}" >
                                    <f:param name="id" value="#{item.id}"/>
                                    <h:outputText value="Valider la demande"/>&nbsp;
                                </h:commandLink>
                                <h:commandLink action="#{currentuser.notValidateCredit}" rendered="#{item.loanWaitingState}" >
                                    <f:param name="id" value="#{item.id}"/>
                                    <h:outputText value="Refuser la demande"/>&nbsp;
                                </h:commandLink>
                                <h:commandLink action="#{currentuser.returnedProjet}" rendered="#{item.lentState || item.returnWaitingState}" >
                                    <f:param name="id" value="#{item.id}"/>
                                    <h:outputText value="Recupere"/>&nbsp;
                                </h:commandLink>
                                <h:outputText rendered="#{item.returnWaitingState}" value="Delais depasse" />&nbsp;
                            </h:column>
                            
                        </h:dataTable>
                        <br/>
                    </h:form>
                </p>
            </ui:define>
            
        </ui:composition> 
    </body> 
</html>